package com.mall.commons.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageResult implements Serializable {

    private Integer pageNum;//当前页码
    private Integer pageSize;//页大小
    private Integer totalPage = 0;//总页数
    private Integer total = 0;//总记录数
    private List<?> list = Collections.emptyList(); //列表

    public PageResult(Integer pageNum, Integer pageSize, Integer total, List list) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.list = list;
        this.total = total;
        this.totalPage = total % this.pageSize == 0 ? (total / this.pageSize) : (total / this.pageSize) + 1;
    }
}
